package cc.telecomdigital.tdstock.activity.groups;

import android.os.Bundle;
import android.widget.TabHost;
import cc.telecomdigital.tdstock.Framework.ActivityGroupHost_Framework;
import cc.telecomdigital.tdstock.Framework.ActivityGroup_Framework;
import cc.telecomdigital.tdstock.Tools.ActivityGroupController;
import cc.telecomdigital.tdstock.activity.groups.foreignexchange.ForeignExchangeActivity;

/**
 * Groups the archive activities, so they can stay within a tab of TabActivity
 * @author haibo
 *
 */
public class ForeignExchangeGroup extends ActivityGroupHost_Framework
{

	public static ForeignExchangeGroup	group;
	// private ArrayList<View> history;
	public static TabHost			tabHost	= null;
	
	//Cause we need a static here to remember our list
	private static ActivityGroupController groupController = null;

	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		//this.history = new ArrayList<View>();
		group = this;
	/*	//set the default activity when enter the group
		View view = getLocalActivityManager().startActivity(
				ForeignExchangeActivity.class.getSimpleName(),
				new Intent(this, ForeignExchangeActivity.class)
						.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP| Intent.FLAG_ACTIVITY_NO_USER_ACTION))
				.getDecorView();

		setContentView(view);*/
	}

	public static void forceToGoToRelatingTab()
	{
		if (tabHost != null)
		{
			tabHost.setCurrentTab(3); //force to go to tab 3
		}
	}

	@Override
	public void onBackPressed()
	{
		//super.onBackPressed();
		getCurrentActivity().onBackPressed(); //do  back pressed action in BaseActivity.  need to  go back to the history page directly?
	}
	
	

	@Override
	public ActivityGroupController CreateActivityGroupHostController() {
		/*if (groupController != null)
			groupController.DestoryController();*/
				
		if (groupController == null)
			groupController = new ActivityGroupController(this);
		else
			groupController.UpdateGroupHost(this);
		return groupController;
	}

	@Override
	public Class<? extends ActivityGroup_Framework> GetPrimaryActivity() {
		return ForeignExchangeActivity.class;
	}
	
	
	/** For External Call **/
	public static ActivityGroupController GetActivityGroupHostControl()
	{
		return groupController;
	}

	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
	}
	
	
	
	

}